#include <stdio.h>
#define LEN 64

int strrindex(const char* s,const char* t){
    int slen = strlen(s);
    int tlen = strlen(t);

    int sindex = slen-1;
    int tindex = tlen-1;

    char* sp = s+slen-1;
    char* tp = t+tlen-1;
    
    while(sindex>=0){
        while(sindex>=0 && *sp != *tp){
            sp--;
            sindex--;
        }

        while(sindex>=0 && tindex>=0 && *sp == *tp){
            sp--;
            tp--;
            sindex--;
            tindex--;
        }
        if(-1 == tindex){
            sindex++;
            break;
        }else{
            tindex = tlen-1;
            tp = t+tindex;
        }
    }
    return sindex;
}

int main(){
    char s[LEN]={0};
    char t[LEN]={0};
    int rindex = 0;

    printf("请输入s:");
    gets(s);
    printf("请输入t:");
    gets(t);
    rindex = strrindex(s,t);
    printf("s=%s t=%s rindex=%d\n", s, t, rindex);

    return 0;
}